package org.raymond.icloud.modules.admin.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.raymond.icloud.apis.admin.entity.TSysUser;
import org.raymond.icloud.common.core.security.model.UsernamepasswordAuthentication;
import org.raymond.icloud.common.core.security.model.UsernamepasswordCertification;
import org.raymond.icloud.modules.admin.service.IAuthService;
import org.raymond.icloud.modules.admin.service.ITSysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Slf4j
@Service("authenticationService")
public class AuthServiceImpl extends UsernamepasswordAuthentication implements IAuthService {
    @Autowired
    private ITSysUserService itSysUserService;

    @Override
    protected UsernamepasswordCertification findByUsername(String username) {
        TSysUser tSysUser = itSysUserService.findByUsername(username);
        if(tSysUser==null) return null;
        UsernamepasswordCertification another = new UsernamepasswordCertification(tSysUser.getUsername(), tSysUser.getPassword());
        another.setId(tSysUser.getId());
        return another;
    }
}
